import {config} from '../config.js'

class HTTP{
  request(params) {
    if(!params.method) {
      params.method = "GET"
    }
    wx.request({
      url: config.api_url+params.url,
      method: params.method,
      header: {
        "content-type":"application/json"
        // "appKey": config.appKey
      },
      data:params.data,
      success: (res) => {
        //坑
        let code = res.statusCode.toString()
        if(code.startsWith('2')){
          params.success && params.success(res.data)
        } else {

        }
        // console.log(res)
      },
      fail: (err) => {

      }
    })
  }
}

export {HTTP}